home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / iconmenu.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  3KB  |  105 lines

  1. #include "iconmenu.h"
  2.  
  3. void IconMenu::calcItemsNumber()
  4.     {
  5.     for(count = 0; itemList[count] != 0; count++)
  6.     ;
  7.     itemSize = pScreenSet->icon_types[itemType];
  8.     }
  9. /////////////////////////
  10. void IconMenu::showItem()
  11.     {
  12.     rect where = getItemCoord();
  13.     Icon icon(loc(where.origin.X + itemDistance.X / 2,
  14.           where.origin.Y + itemDistance.Y / 2),
  15.           itemList[pos - 1], itemType);
  16.     imageP image = icon.extract();
  17.     putimage(where.origin, image, COPY_PUT);
  18.     delete image;
  19.     }
  20. /////////////////////////
  21. /*   show() is not absolutely necessary here. Remark it if you
  22.          intend to use computers with fast disk operations (cash).
  23.          If show() remarked, the ChoiseBox::show() will use calls to
  24.          showItem(), and each call will open - close icon file.
  25. */
  26. void IconMenu::show()
  27.     {
  28.     Window::show();
  29.     Window::clrscr();
  30.     if(!available || (itemStrings == NULL && itemList == NULL))
  31.     return;
  32.     Icon icon(loc(0, 0), itemList[pos - 1], itemType);
  33.     FILE* iconFile;
  34.     char* fileName = strdup(icon.icon_open());
  35.     if((iconFile = fopen(fileName, "r+b")) == NULL)
  36.     {
  37.         delete fileName;
  38.     return;
  39.         }
  40.     int p = pos;
  41.     for(int i = 1; i <= raw; i++)
  42.     {
  43.     for(int j = 1; j <= column; j++)
  44.         {
  45.         pos = start + (i - 1) * column + j - 1;
  46.             loc size = icon_size(itemType);
  47.             int i_size = ((size.X + 1 + 7) >> 3 << 2) * (size.Y + 1) + sizeof(imageP);
  48.             imageP image = (imageP)malloc(i_size + 10);
  49.  
  50.             get_image(iconFile, itemList[pos - 1],
  51.             image, i_size);
  52.             rect where = getItemCoord();
  53.             putimage(where.origin, image, COPY_PUT);
  54.             delete image;
  55.  
  56.         if(pos == count)
  57.         break;
  58.         }
  59.     if(pos == count)
  60.         break;
  61.     }
  62.     fclose(iconFile);
  63.     delete fileName;
  64.     pos = p;
  65.     moveTo(pos);
  66.     }
  67. ///////////////////////////
  68. /*
  69. void main()
  70.     {
  71.     if(!init_KNOW_HOW())
  72.         return;
  73.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  74.     bar(0, 0, getmaxx(), getmaxy());
  75.  
  76.     int LIST[] = { 1, 2, 3, 1, 2, 3, 3, 2, 1, 2, 0 };
  77.  
  78.     IconMenu i(rect(10, 10, 30, 16), "window.pcy", "ICON MENU",
  79.            "0123456789", 1, 1, SMALL_ICON, LIST, loc(3, 3),
  80.            rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
  81.            FIXED, 10, SHOW_BORDER, SHOW_BORDER, 21, 22);
  82.     i.show();
  83.     i.exe();
  84.     i.hide();
  85.  
  86.     IconMenu i0(rect(10, 10, 50, 20), "window.pcy", "ICON MENU",
  87.            "0123456789", 1, 1, MEDIUM_ICON, LIST, loc(5, 8),
  88.            rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
  89.            FIXED, 10, SHOW_BORDER, SHOW_BORDER, 23, 24);
  90.     i0.show();
  91.     i0.exe();
  92.     i0.hide();
  93.  
  94.     IconMenu i1(rect(10, 4, 70, 20), "window.pcy", "ICON MENU",
  95.            "0123456789", 1, 1, LARGE_ICON, LIST, loc(5, 8),
  96.            rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
  97.            FIXED, 10, SHOW_BORDER, SHOW_BORDER, 25, 26);
  98.     i1.show();
  99.     i1.exe();
  100.     i1.hide();
  101.  
  102.     close_KNOW_HOW();
  103.     closegraph();
  104.     }
  105. */